﻿namespace IP_Package
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using IP_Package.GUI;

    /// <summary>
    /// THE MAIN FORM
    /// </summary>
    public partial class Form1 : Form
    {
        /// <summary>
        /// object of type open
        /// </summary>
        private IPPackage.ImageOperation.Open img = new IPPackage.ImageOperation.Open();

        /// <summary>
        /// object of type open to open second img
        /// </summary>
        private IPPackage.ImageOperation.Open img2 = new IPPackage.ImageOperation.Open();

        /// <summary>
        /// the processing image
        /// </summary>
        private Bitmap image;

        /// <summary>
        /// Type of noise would add
        /// </summary>
        private Type typeOfNoise;

        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        public Form1()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// type of noise
        /// </summary>
        public enum Type
        {
            /// <summary>
            /// salt and pepper noise
            /// </summary>
            SaltAndPepper,

            /// <summary>
            /// uniform noise
            /// </summary>
            Uniform,

            /// <summary>
            /// gaussian noise
            /// </summary>
            Gaussian,

            /// <summary>
            /// Periodic noise
            /// </summary>
            Periodic
        }

        /// <summary>
        /// Handles the Click event of the openToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string opendFileName = openFileDialog1.FileName;
                    string opendFileName2 = openFileDialog1.SafeFileName;
                    this.image = this.img.OpenImage(opendFileName);
                    this.PicImageOrginal.Image = this.image;
                    ////set Image information
                    this.lbHieght.Text = this.image.Height.ToString();
                    this.lbWidth.Text = this.image.Width.ToString();
                    string[] fileFormat = opendFileName.Split('.');
                    this.lbImageFormat.Text = fileFormat[1] + " file";
                }
                catch
                {
                    MessageBox.Show("open fail. make sure for format of file");
                }
                ////this.picbBrit_contrast.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the exitToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// Handles the Click event of the translateToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void TranslateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.Translate new_Tran = new IP_Package.GUI.Translate();
            new_Tran.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_Tran.ShowDialog();
            if (new_Tran.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Tran.BufferOfImage;
                this.image = new_Tran.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the reSizeToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ReSizeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.ResizeF new_Resize = new IP_Package.GUI.ResizeF();
            new_Resize.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_Resize.ShowDialog();
            if (new_Resize.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Resize.BufferOfImage;
                this.image = new_Resize.ResultImg;
                this.PicImageOrginal.Image = this.image;
                this.lbWidth.Text = this.img.BufferOfImage.GetLength(0).ToString();
                this.lbHieght.Text = this.img.BufferOfImage.GetLength(1).ToString();
            }
        }

        /// <summary>
        /// Handles the Click event of the grayToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GrayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Bitmap newImg = this.img.GrayImg();
                this.PicImageOrginal.Image = newImg;
                this.img.BufferOfImage = this.img.NewBufferOfImage;
            }
            catch
            {
                MessageBox.Show("must insert image to make it gray");
            }
        }

        /// <summary>
        /// Handles the Click event of the histogramToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void HistogramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (this.checkGray.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGray();
                    Bitmap graphImg = graph.Draw(graph1, Color.Gray);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.checkRed.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoRed();
                    Bitmap graphImg = graph.Draw(graph1, Color.Red);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.checkBlue.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoBlue();
                    Bitmap graphImg = graph.Draw(graph1, Color.Blue);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.CheckGreen.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGreen();
                    Bitmap graphImg = graph.Draw(graph1, Color.Green);
                    this.pbHistograph.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckGreen control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckGreen_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (this.CheckGreen.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGreen();
                    Bitmap graphImg = graph.Draw(graph1, Color.Green);
                    this.pbHistograph.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckGray control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckGray_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (this.checkGray.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGray();
                    Bitmap graphImg = graph.Draw(graph1, Color.Gray);
                    this.pbHistograph.Image = graphImg;
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckRed control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckRed_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (this.checkRed.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoRed();
                    Bitmap graphImg = graph.Draw(graph1, Color.Red);
                    this.pbHistograph.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the CheckBlue control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void CheckBlue_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (this.checkBlue.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoBlue();
                    Bitmap graphImg = graph.Draw(graph1, Color.Blue);
                    this.pbHistograph.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the Click event of the brightnessToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BrightnessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.ContrastAndBrightness new_brightness = new IP_Package.GUI.ContrastAndBrightness();
            new_brightness.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_brightness.ShowDialog();
            if (new_brightness.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_brightness.BufferOfImage;
                this.image = new_brightness.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the ContrToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ContrToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.ContrastAndBrightness new_contrast = new IP_Package.GUI.ContrastAndBrightness();
            new_contrast.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_contrast.ShowDialog();
            if (new_contrast.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_contrast.BufferOfImage;
                this.image = new_contrast.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the GToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.GamaForm new_gamma = new IP_Package.GUI.GamaForm();
            new_gamma.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_gamma.ShowDialog();
            if (new_gamma.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_gamma.BufferOfImage;
                this.image = new_gamma.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the equlizationToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void EqulizationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPPackage.ImageOperation.HistoOperation hisEualization = new IPPackage.ImageOperation.HistoOperation();
            hisEualization.BufferOfImage = this.img.BufferOfImage;
            try
            {
                this.image = hisEualization.Equalization();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = hisEualization.NewBufferOfImage;
            }
            catch
            {
                MessageBox.Show("operation fail. make sure for your data");
            }
        }

        /// <summary>
        /// Handles the Click event of the NegativeToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void NegativeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                IPPackage.ImageAlgebra.OneImgOperation negativeOper = new IPPackage.ImageAlgebra.OneImgOperation();
                negativeOper.BufferOfImage = this.img.BufferOfImage;
                Bitmap newImg = negativeOper.MakeNegative();
                this.PicImageOrginal.Image = newImg;
                this.img.BufferOfImage = negativeOper.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make it negative");
                }
                else
                {
                    MessageBox.Show("operation fail. make sure for your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the AddOrSubToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void AddOrSubToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.Calculation_form new_ope = new IP_Package.GUI.Calculation_form();
            new_ope.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_ope.ShowDialog();
            if (new_ope.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_ope.BufferOfImage;
                this.image = new_ope.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the quantizationToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void QuantizationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.QuantizationForm new_qua = new IP_Package.GUI.QuantizationForm();
            new_qua.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_qua.ShowDialog();
            if (new_qua.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_qua.BufferOfImage;
                this.image = new_qua.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the MatchingToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MatchingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.Matching_form new_match = new IP_Package.GUI.Matching_form();
            new_match.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_match.ShowDialog();
            if (new_match.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_match.BufferOfImage;
                this.image = new_match.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Paint event of the PicImageOrginal control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        private void PicImageOrginal_Paint(object sender, PaintEventArgs e)
        {
            if (this.PicImageOrginal.Image != null)
            {
                IPPackage.ImageOperation.Histogram graph = new IPPackage.ImageOperation.Histogram();
                graph.BufferOfImage = this.img.BufferOfImage;
                if (graph.BufferOfImage == null)
                {
                    MessageBox.Show("no image to draw histogram");
                }

                if (this.checkGray.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGray();
                    Bitmap graphImg = graph.Draw(graph1, Color.Gray);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.checkRed.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoRed();
                    Bitmap graphImg = graph.Draw(graph1, Color.Red);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.checkBlue.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoBlue();
                    Bitmap graphImg = graph.Draw(graph1, Color.Blue);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.CheckGreen.Checked == true)
                {
                    long[] graph1;
                    graph1 = graph.HistoGreen();
                    Bitmap graphImg = graph.Draw(graph1, Color.Green);
                    this.pbHistograph.Image = graphImg;
                }

                if (this.radioRedCheck.Checked == true)
                {
                    try
                    {
                        Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                        matlapMagu.BufferOfImage = this.img.BufferOfImage;
                        if (this.radioRedCheck.Checked == true)
                        {
                            Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Red");
                            this.picMagnitude.Image = graphImg;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("no image to draw histogram");
                    }
                }
                else if (this.radioGreenCheck.Checked == true)
                    {
                        try
                        {
                            Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                            matlapMagu.BufferOfImage = this.img.BufferOfImage;
                            if (this.radioGreenCheck.Checked == true)
                            {
                                Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Green");
                                this.picMagnitude.Image = graphImg;
                            }
                        }
                        catch
                        {
                            MessageBox.Show("no image to draw histogram");
                        }
                    }
                else if (this.radioBlueCheck.Checked == true)
                {
                    try
                    {
                        Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                        matlapMagu.BufferOfImage = this.img.BufferOfImage;
                        if (this.radioBlueCheck.Checked == true)
                        {
                            Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Blue");
                            this.picMagnitude.Image = graphImg;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("no image to draw histogram");
                    }
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the MeanFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MeanFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.SmoothingFilter filter = new IP_Package.GUI.SmoothingFilter();
            filter.SetInfo(this.img.BufferOfImage, this.PicImageOrginal.Image, "mean");
            filter.ShowDialog();
            if (filter.SaveOrNot == true)
            {
                this.img.BufferOfImage = filter.BufferOfImage1;
                this.image = filter.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the GaussianFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GaussianFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.SmoothingFilter filter = new IP_Package.GUI.SmoothingFilter();
            filter.SetInfo(this.img.BufferOfImage, this.PicImageOrginal.Image, "gaussian");
            filter.ShowDialog();
            if (filter.SaveOrNot == true)
            {
                this.img.BufferOfImage = filter.BufferOfImage1;
                this.image = filter.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the LaplacianToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LaplacianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.EdgeDetection newEdge = new IP_Package.Operations.Neighbor_operations.EdgeDetection();
                newEdge.BufferOfImage = this.img.BufferOfImage;
                newEdge.MyDetection = Operations.Neighbor_operations.EdgeDetection.Detection.Point;
                this.image = newEdge.MakeEdgeDetection();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newEdge.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make edge detection operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the HorizontalToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void HorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.EdgeDetection newEdge = new IP_Package.Operations.Neighbor_operations.EdgeDetection();
                newEdge.BufferOfImage = this.img.BufferOfImage;
                newEdge.MyDetection = Operations.Neighbor_operations.EdgeDetection.Detection.Horizontal;
                this.image = newEdge.MakeEdgeDetection();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newEdge.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make edge detection operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the VerticalToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void VerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.EdgeDetection newEdge = new IP_Package.Operations.Neighbor_operations.EdgeDetection();
                newEdge.BufferOfImage = this.img.BufferOfImage;
                newEdge.MyDetection = Operations.Neighbor_operations.EdgeDetection.Detection.Vertical;
                this.image = newEdge.MakeEdgeDetection();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newEdge.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make edge detection operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the RightDiagonalToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RightDiagonalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.EdgeDetection newEdge = new IP_Package.Operations.Neighbor_operations.EdgeDetection();
                newEdge.BufferOfImage = this.img.BufferOfImage;
                newEdge.MyDetection = Operations.Neighbor_operations.EdgeDetection.Detection.RightDiagonal;
                this.image = newEdge.MakeEdgeDetection();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newEdge.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make edge detection operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the LeftDiagonalToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LeftDiagonalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.EdgeDetection newEdge = new IP_Package.Operations.Neighbor_operations.EdgeDetection();
                newEdge.BufferOfImage = this.img.BufferOfImage;
                newEdge.MyDetection = Operations.Neighbor_operations.EdgeDetection.Detection.LeftDiagonal;
                this.image = newEdge.MakeEdgeDetection();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newEdge.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make edge detection operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the LineDetectionLaplacianToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LineDetectionLaplacianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.Sharpening newSharp = new IP_Package.Operations.Neighbor_operations.Sharpening();
                newSharp.BufferOfImage = this.img.BufferOfImage;
                newSharp.MySharpening = Operations.Neighbor_operations.Sharpening.SharpeningType.Point;
                this.image = newSharp.MakeSharpening();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newSharp.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make sharpening operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the HorizontalToolStripMenuItem1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void HorizontalToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.Sharpening newSharp = new IP_Package.Operations.Neighbor_operations.Sharpening();
                newSharp.BufferOfImage = this.img.BufferOfImage;
                newSharp.MySharpening = Operations.Neighbor_operations.Sharpening.SharpeningType.Horizontal;
                this.image = newSharp.MakeSharpening();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newSharp.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make sharpening operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the VerticalToolStripMenuItem1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void VerticalToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.Sharpening newSharp = new IP_Package.Operations.Neighbor_operations.Sharpening();
                newSharp.BufferOfImage = this.img.BufferOfImage;
                newSharp.MySharpening = Operations.Neighbor_operations.Sharpening.SharpeningType.Vertical;
                this.image = newSharp.MakeSharpening();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newSharp.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make sharpening operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the RightDiagonalToolStripMenuItem1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RightDiagonalToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.Sharpening newSharp = new IP_Package.Operations.Neighbor_operations.Sharpening();
                newSharp.BufferOfImage = this.img.BufferOfImage;
                newSharp.MySharpening = Operations.Neighbor_operations.Sharpening.SharpeningType.RightDiagonal;
                this.image = newSharp.MakeSharpening();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newSharp.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make sharpening operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the Click event of the LeftDiagonalToolStripMenuItem1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LeftDiagonalToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                Operations.Neighbor_operations.Sharpening newSharp = new IP_Package.Operations.Neighbor_operations.Sharpening();
                newSharp.BufferOfImage = this.img.BufferOfImage;
                newSharp.MySharpening = Operations.Neighbor_operations.Sharpening.SharpeningType.LeftDiagonal;
                this.image = newSharp.MakeSharpening();
                this.PicImageOrginal.Image = this.image;
                this.img.BufferOfImage = newSharp.NewBufferOfImage;
            }
            catch
            {
                if (this.PicImageOrginal.Image == null)
                {
                    MessageBox.Show("no image to make sharpening operation");
                }
                else
                {
                    MessageBox.Show("operation fail make sure your data");
                }
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the RadioRedCheck control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RadioRedCheck_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                matlapMagu.BufferOfImage = this.img.BufferOfImage;
                if (this.radioRedCheck.Checked == true)
                {
                    Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Red");
                    this.picMagnitude.Image = graphImg;
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the RadioGreenCheck control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RadioGreenCheck_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                matlapMagu.BufferOfImage = this.img.BufferOfImage;
                if (this.radioGreenCheck.Checked == true)
                {
                    Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Green");
                    this.picMagnitude.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the RadioBlueCheck control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RadioBlueCheck_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                Operations.MATLAP_operations.MATLAPOper matlapMagu = new Operations.MATLAP_operations.MATLAPOper();
                matlapMagu.BufferOfImage = this.img.BufferOfImage;
                if (this.radioBlueCheck.Checked == true)
                {
                    Bitmap graphImg = matlapMagu.CalcuMagnitudeTODetemineColor("Blue");
                    this.picMagnitude.Image = graphImg;
                }
            }
            catch
            {
                MessageBox.Show("no image to draw histogram");
            }
        }

        /// <summary>
        /// Handles the Click event of the ConnectWithMatlapToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ConnectWithMatlapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.MatLapConnectOperation new_MatlapOper = new GUI.MatLapConnectOperation();
            new_MatlapOper.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_MatlapOper.ShowDialog();    
        }

        /// <summary>
        /// Handles the Click event of the ConvertToFrequencyDomainToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ConvertToFrequencyDomainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.MatLapConnectOperation new_MatlapOper = new GUI.MatLapConnectOperation();
            new_MatlapOper.SetType("To Freq");
            new_MatlapOper.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_MatlapOper.ShowDialog();
        }

        /// <summary>
        /// Handles the Click event of the ConvertTSpatialDomainToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ConvertTSpatialDomainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.MatLapConnectOperation new_MatlapOper = new GUI.MatLapConnectOperation();
            new_MatlapOper.SetType("To Spat");
            new_MatlapOper.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_MatlapOper.ShowDialog();
        }

        /// <summary>
        /// Handles the Click event of the HPFToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void HPFToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.MATLAPFilters new_MATLAPFilter = new IP_Package.GUI.MATLAPFilters();
            new_MATLAPFilter.SetInfo("HPF", this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_MATLAPFilter.ShowDialog();
            if (new_MATLAPFilter.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_MATLAPFilter.BufferOfImage;
                this.image = new_MATLAPFilter.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the LowPassFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LowPassFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.MATLAPFilters new_MATLAPFilter = new IP_Package.GUI.MATLAPFilters();
            new_MATLAPFilter.SetInfo("LPF", this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage);
            new_MATLAPFilter.ShowDialog();
            if (new_MATLAPFilter.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_MATLAPFilter.BufferOfImage;
                this.image = new_MATLAPFilter.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the SaltAndPepperToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void SaltAndPepperToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.typeOfNoise = Type.SaltAndPepper;
            this.grpSaltAndPepper.Visible = true;
            this.BtnAddNoise.Visible = true;
        }

        /// <summary>
        /// Handles the Click event of the BtnAddNoise control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnAddNoise_Click(object sender, EventArgs e)
        {
            Operations.Restoration.Add_noise.NoiseAdded noise = new Operations.Restoration.Add_noise.NoiseAdded();
            if (this.typeOfNoise == Type.SaltAndPepper)
            {
                noise.BufferOfImage = this.img.BufferOfImage;
                this.image = noise.AddSaltAndPepperNoise(float.Parse(this.txtPs.Text), float.Parse(this.txtPp.Text));
                this.img.BufferOfImage = noise.BufferOfImage;
              this.PicImageOrginal.Image = this.image;
              this.grpSaltAndPepper.Visible = false;
              this.BtnAddNoise.Visible = false;
            }

            if (this.typeOfNoise == Type.Periodic)
            {
                noise.BufferOfImage = this.img.BufferOfImage;
                this.image = noise.AddPeriodicNoise(float.Parse(this.txtAmplitude.Text), float.Parse(this.txtFrecX.Text), float.Parse(this.txtFrecY.Text), float.Parse(this.txtPX.Text), float.Parse(this.txtPY.Text));
                this.img.BufferOfImage = noise.NewBufferOfImage;
                this.PicImageOrginal.Image = this.image;
                this.grpPeriodic.Visible = false;
                this.BtnAddNoise.Visible = false;
            }

            if (this.typeOfNoise == Type.Uniform)
            {
                noise.BufferOfImage = this.img.BufferOfImage;
                this.image = noise.AddUniformNoise(int.Parse(this.txtAUniform.Text), int.Parse(this.txtBUniform.Text), float.Parse(this.txtPrecentage.Text));
                this.img.BufferOfImage = noise.NewBufferOfImage;
                this.PicImageOrginal.Image = this.image;
                this.BtnAddNoise.Visible = false;
                this.grpUniform.Visible = false;
            }

            if (this.typeOfNoise == Type.Gaussian)
            {
                noise.BufferOfImage = this.img.BufferOfImage;
                this.image = noise.AddGaussianNoise(float.Parse(this.txtMean.Text), float.Parse(this.txtSigma.Text), float.Parse(this.txtPrecentageGaussian.Text));
                this.img.BufferOfImage = noise.NewBufferOfImage;
                this.PicImageOrginal.Image = this.image;
                this.BtnAddNoise.Visible = false;
                this.grpGaussian.Visible = false;
            }
        }

        /// <summary>
        /// Handles the Click event of the uniformToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void UniformToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.typeOfNoise = Type.Uniform;
            this.grpUniform.Visible = true;
            this.BtnAddNoise.Visible = true;
        }

        /// <summary>
        /// Handles the Click event of the gaussianToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GaussianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.typeOfNoise = Type.Gaussian;
            this.grpGaussian.Visible = true;
            this.BtnAddNoise.Visible = true;
        }

        /// <summary>
        /// Handles the Click event of the PeriodicToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void PeriodicToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.typeOfNoise = Type.Periodic;
            this.grpPeriodic.Visible = true;
            this.BtnAddNoise.Visible = true;
        }

        /// <summary>
        /// Handles the Click event of the GeometricMeanFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void GeometricMeanFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Mean");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the MaxFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MaxFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Max");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the MinFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MinFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Min");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the MedianFilterToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MedianFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Median");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the MidpointToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MidpointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Midpoint");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the NotchRejectToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void NotchRejectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.RemoveNoiseFreq new_Remove = new IP_Package.GUI.RemoveNoiseFreq();
            new_Remove.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage, "Notch reject");
            new_Remove.ShowDialog();
            if (new_Remove.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Remove.BufferOfImage;
                this.image = new_Remove.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the NotchPassToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void NotchPassToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.RemoveNoiseFreq new_Remove = new IP_Package.GUI.RemoveNoiseFreq();
            new_Remove.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage, "Notch pass");
            new_Remove.ShowDialog();
            if (new_Remove.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Remove.BufferOfImage;
                this.image = new_Remove.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the BandRejectToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BandRejectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.RemoveNoiseFreq new_Remove = new IP_Package.GUI.RemoveNoiseFreq();
            new_Remove.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage, "Band reject");
            new_Remove.ShowDialog();
            if (new_Remove.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Remove.BufferOfImage;
                this.image = new_Remove.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the BandPassToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BandPassToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GUI.RemoveNoiseFreq new_Remove = new IP_Package.GUI.RemoveNoiseFreq();
            new_Remove.SetInfo(this.PicImageOrginal.Image, this.lbWidth.Text, this.lbHieght.Text, this.img.BufferOfImage, "Band pass");
            new_Remove.ShowDialog();
            if (new_Remove.SaveOrNot1 == true)
            {
                this.img.BufferOfImage = new_Remove.BufferOfImage;
                this.image = new_Remove.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }

        /// <summary>
        /// Handles the Click event of the AdaptiveMedianToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void AdaptiveMedianToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Remove_Noise opreation = new Remove_Noise();
            opreation.SetInfo(this.PicImageOrginal.Image, this.img.BufferOfImage, "Adaptive Median");
            opreation.ShowDialog();
            if (opreation.SaveOrNot == true)
            {
                this.img.BufferOfImage = opreation.NewBufferOfImage;
                this.image = opreation.ResultImg;
                this.PicImageOrginal.Image = this.image;
            }
        }
        }
    }
